%y = mlp2_run(x,w12,w23,phi) runs a 2-layer neural network.
%
%Outputs:
%y - output vector.
%
%Inputs:
%x - input vector.
%w12 - synaptic weights matrix for layer 1.
%w23 - synaptic weights matrix for layer 2.
%phi - activation function.

function y = mlp2_run(x,w12,w23,phi)
    m = [length(x),size(w23,2),size(w23,1)]; %[input size, hidden layer size, output size]

    %Forward pass
    v1 = sum(repmat(x,m(2),1).*w12,2).'; %output of layer 1 before activation function
    y1 = phi(v1); %ouput of layer 1
    v2 = sum(repmat(y1,m(3),1).*w23,2).'; %output of layer 2 before activation function
    y2 = phi(v2); %output of layer 2
    
    y = y2; %assigning output
end